#!/usr/bin/perl
print "input strings and ended by CTRL + D\n";
chomp(@strings = <STDIN>);
@strings_reserse = reverse @strings;

print "the reverse strings are:\n";
print "@{strings_reserse}";
print "\n";

print "--------------------------------\n";
@names = qw{fred betty barney dino wilma pebbles bamm-bamm};
print "input the index of name:\n";
chomp(@indexes = <STDIN>);

foreach (@indexes){
	print "@names[$_ - 1] ";
}
print "\n";

print "--------------------------------\n";
print "input strings and ended by CTRL + D\n";
@strings = <STDIN>;
print "after sorted:\n";
@sortedStrings = sort(@strings);
print @sortedStrings;
print "\n";

print "after sorted in one line :\n";
chomp(@sortedStrings);
print "@{sortedStrings}\n";


print "\n------OK\n";
